package com.xuecheng.content.api;

import com.xuecheng.content.model.dto.CourseTeacherDto;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: 40斤
 * @CreateTime: 2024-07-30  11:50
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@Api(value = "教师设置管理接口",tags = "教师设置管理接口")
public class courseTeacherController {
    @Autowired
    CourseTeacherService courseTeacherService;

    @GetMapping("/courseTeacher/list/{courseId}")
    @ApiOperation("查询课程教师信息")
    public List<CourseTeacher> getCourseTeacherList(@PathVariable Long courseId) {
        return courseTeacherService.getTeacherListByCourseId(courseId);
    }

    @PostMapping("/courseTeacher")
    @ApiOperation("新增课程教师信息")
    public CourseTeacherDto saveCourseTeacher(@RequestBody CourseTeacherDto courseTeacherDto) {
        if (courseTeacherDto.getId() == null) {
            //新增
            return courseTeacherService.saveCourseTeacher(courseTeacherDto);
        }else {
            //修改
            return courseTeacherService.updateCourseTeacher(courseTeacherDto);
        }
    }

}